﻿using ShanNiang.Hosting.Enumerate;
using ShanNiang.Hosting.Extensions;

namespace ShanNiang.Hosting.Common
{

    /// <summary>
    /// Api内容响应
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ApiResult<T>
    {
        /// <summary>
        /// 响应结果
        /// </summary>
        public GlobalErrorCode Code { get; set; }
        /// <summary>
        /// 错误消息
        /// </summary>
        public string? ErroMessage { get; set; }

        public ApiResult()
        {
            Code = GlobalErrorCode.Ok;
        }
        public ApiResult(GlobalErrorCode code)
        {
            Code = code;
            ErroMessage = code.GetDescription();
        }
        public ApiResult(GlobalErrorCode code, string? erroMessage) : this(code)
        {
            ErroMessage = erroMessage;
        }

        public ApiResult(T result) : this()
        {
            Data = result;
        }
        /// <summary>
        /// 响应的数据
        /// </summary>
        public T? Data { get; set; }
    }
    /// <summary>
    /// Api内容响应
    /// </summary>
    public class ApiResult : ApiResult<object>
    {

    }
}
